<?php
require("conn.php");
if (!function_exists("GetSQLValueString")) {
	function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
	{
	  if (PHP_VERSION < 6) {
		$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
	  }
	
	  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
	
	  switch ($theType) {
		case "text":
		  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
		  break;    
		case "long":
		case "int":
		  $theValue = ($theValue != "") ? intval($theValue) : "NULL";
		  break;
		case "double":
		  $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
		  break;
		case "date":
		  $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
		  break;
		case "defined":
		  $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
		  break;
	  }
	  return $theValue;
	}
}
$aid = $_POST["id"];
$sid = $_POST["sid"];
$published = $_POST["published"];
$image =  $_POST["image"];
$tag = $_POST["tag"];
$vi_title=$_POST["vi_title"];
$vi_summary=$_POST["vi_summary"];
$vi_content=$_POST["vi_content"];
$en_title=$_POST["en_title"];
$en_summary= $_POST["en_summary"];
$en_content=$_POST["en_content"];

$st=sprintf("update tblarticle set section_id=%s,published=%s,image=%s,tag=%s,vi_title=%s,vi_summary=%s,vi_content=%s,en_title=%s,en_summary=%s,en_content=%s where id=%s",																															
								   	GetSQLValueString($sid,"int"),
								   	GetSQLValueString($published,"int"),
								   	GetSQLValueString($image,"text"),
								   	GetSQLValueString($tag,"text"),
								   	GetSQLValueString($vi_title,"text"),																																																																																																														
									GetSQLValueString($vi_summary,"text"),																																																																																																																																																																																																																																				
									GetSQLValueString($vi_content,"text"),
									GetSQLValueString($en_title,"text"),																																																																																																														
									GetSQLValueString($en_summary,"text"),																																																																																																																																																																																																																																				
									GetSQLValueString($en_content,"text"),
									GetSQLValueString($aid,"int"));

$rs=mysql_query($st);
			 
if(!$rs)
{
?>
	<script language="javascript">
		alert("Sửa bài viết không thành công");
		window.location="article";
	</script>
<?php
}
else
{
		
?>
	<script language="javascript">
		alert("Sửa bài viết thành công");
		window.location="article";
	</script>
<?php
}

?>
